define(function(require, exports, module) {
  'use strict';

  var Search = require('../common/search/search');
  var Select = require('../common/select/select');

  var opts = [
    '<a href="javascript:;" data-id="{{id}}" data-role="processed">已处理</a>',
    '<a href="javascript:;" data-id="{{id}}" data-role="ignore">忽略</a>'
  ];
  var search = new Search({
    url: 'feedbackList',
    delUrl: 'feedbackDel',
    keepHistory: false,
    dateCfg: {
      disabled: true
    },
    formCfg: {
      data: {
        groups: [{
          // label: '所属模板',
          colspan: null,
          attrs: {
            type: 'select',
            name: 'docStatus',
            placeholder: '状态'
          },
          options: [{
            value: '',
            text: '全部'
          }, {
            value: '00',
            text: '未处理'
          }, {
            value: '20',
            text: '已处理'
          }, {
            value: '10',
            text: '忽略'
          }]
        }, {
          colspan: null,
          value: '<i class="fa fa-search"></i> 搜索',
          attrs: {
            type: 'submit'
          }
        }]
      },
      events: {
        render: function() {
        }
      }
    },
    gridCfg: {
      columns: [{
        key: 'docCreateTime',
        name: '反馈时间'
      }, {
        key: 'docCreatorName',
        name: '用户'
      }, {
        key: 'type',
        name: '类型',
        template: '{{{typeName type}}}'
      }, {
        key: 'desc',
        name: '反馈内容'
      }, {
        key: 'docStatus',
        name: '状态',
        template: '{{{statusName docStatus}}}'
      }, {
        name: '操作',
        template: opts.join('')
      }]
    },
    gridHelpers: {
      typeName: function(type) {
        var TYPE = {
          '00': '<span class="label label-info">其它</span>',
          '10': '<span class="label label-danger">bug信息</span>'
        };
        return TYPE[type || '10'];
      },
      statusName: function(status) {
        var STATUS = {
          '00': '<span class="label label-danger">未处理</span>',
          '10': '<span class="label label-info">忽略</span>',
          '20': '<span class="label label-success">已处理</span>'
        };
        return STATUS[status || '10'];
      }
    },
    events: {
      render: function() {

      }
    },
    delegates: {
      'click [data-role=view]': function() {
        window.location.href = '/admin/user/view.html';
      },
      'click [data-role=freeze]': function(e) {}
    }
  });

  new Select({
    field: search.$('[name=docStatus]')
  });
});
